<template>
    <div class="community views-container">
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <router-link tag="span" to="/merchandise/communityAdd">
                <el-button size="small" type="primary">添加客服</el-button>
            </router-link>
        </div>
         <div class="wlm-table-header">
            <el-form :model="tableFormatData.customer.files" size="small" label-width="80px" class="retail-form" label-position="right">
                <div style="display:flex;">
                    <el-form-item label="客服类型：" class="search">
                        <el-select v-model="tableFormatData.customer.files.community_type" placeholder="请选择客服类型" style="width:200px;">
                                <el-option :label="'社群'" :value="'1'">
                                </el-option>
                                <el-option :label="'客服'" :value="'2'">
                                </el-option>
                                <el-option :label="'公众号'" :value="'3'">
                                </el-option>
                                <el-option :label="'电话'" :value="'4'">
                                </el-option>
                            </el-select>
                    </el-form-item>
                    <el-form-item label="名称：" class="search" style="margin-right:1000px;">
                     <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.customer.files.title" placeholder="请输入用户昵称" style="width:200px;"></el-input>
                </el-form-item>
                </div>
                
                <el-form-item label="" class="filter-btns">
                    <el-button v-waves type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
         <div class="wlm-table-content">
             <!--  -->
             <el-table  :ref="tableFormatData.customer.key" :data="tableFormatData.customer.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <el-table-column prop="date" label="ID" >
                    <template slot-scope="scope">
                        <span>{{ scope.row.id}}</span>
                        <!-- <img v-if="scope.row.headimg.length>0" height="32" width="32" :src="scope.row.headimg[0]['file_path']" alt=""> -->
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="客服类型" >
                    <template slot-scope="scope">
                        <span v-if="scope.row.community_type==1" >社群</span>
                        <span v-if="scope.row.community_type==2" >客服</span>
                        <span v-if="scope.row.community_type==3" >公众号</span>
                        <span v-if="scope.row.community_type==4" >电话</span>
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="名称" >
                    <template slot-scope="scope">
                        <span>{{scope.row.title}}</span>
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="头像" >
                    <template slot-scope="scope">
                        <img v-if="!!scope.row.headimg" height="32" width="32" :src="scope.row.headimg" alt="">
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="内容描述" >
                    <template slot-scope="scope">
                        <span>{{scope.row.des}}</span>
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="客服电话/微信号" >
                    <template slot-scope="scope">
                        {{scope.row.mobile}}{{scope.row.wechat}}
                    </template>
                </el-table-column>
                 <el-table-column prop="date" label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                         <router-link class="wlm-text" tag="span" :to="{path:'/merchandise/communityAdd', query:{id:scope.row.id}}">
                                <el-button type="text">编辑</el-button>
                            </router-link>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="deltable(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
              
            </el-table>
            <div class="pagination-content flex-row flex-justify-e flex-align-c">
                <!-- <el-row class="pagination-btns">
                    <el-checkbox class="check-all"  true-label="1" false-label="0" v-model="tableFormatData.platformPack.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row> -->
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.customer.pagination.page" :page-sizes="tableFormatData.customer.pagination.pagesizes" :page-size.sync="tableFormatData.customer.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.customer.pagination.total : 0">
                </el-pagination>
            </div>
         </div>
    </div>
    </div>
   
</template>     
<script>
import {
  servicesList,
  delServices
} from '@/api/merchant'
import waves from '@/directive/waves' // Waves directive
import mixins from '@/mixins/mixins'
export default {
    mixins: [mixins.getters('Table')],
    name: 'customer',
     directives: {
    waves
  },
    data(){
        return{
           tableFormatData:{
               current: 'customer',
                customer: {
                key: 'customer',
                api: {
                    getList: servicesList,
                },
                tableData: [],
                files: {
                    ids: [],
                    checkall: '0'
                },
                pagination: {
                    community_type:'',
                    title:'',
                    page: 1,
                    list_rows: 10,
                    pagesizes: [10, 20, 50],
                    total: 0
                }
                }
           } 
        }
    },
    methods:{
        deltable(id){
            delServices({id:id}).then(res=>{
                const { data: { code, msg } } = res
                 this.$confirm('确定删除选择的数据项?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                        }).then(() => {
                             if (code === 1) {
                            this.$message.success(msg)
                             this.filesEmpty()
                        } else {
                            this.$message.error(msg)
                        }
                      
                        }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });          
                        });
                   

                // console.log("111111",res)
            })
        }
    }
}
</script>
<style lang="scss" scoped>
</style>